#ifndef FILE_DV_SOURCE_H
#define FILE_DV_SOURCE_H

#include "dvsource.h"
#include <fstream>
using namespace std;
#include "rtp.h"
#include "Constants.h"

class FileDVSource : public IDVSource
{
public:
	FileDVSource(const string& file_name, bool loop);
	virtual bool Init();
	virtual DVPacket GetPacket();
	virtual bool Cleanup();
	virtual double GetTraffic();
private:
	string	file_name;
	bool	loop;
	ifstream fin;
	static const int framebuf_capacity = 100;
	static const int frame_size = NTSC_FRAME_SIZE;
	static const int framebuf_size = frame_size * framebuf_capacity;
	char	framebuf[framebuf_size];
	int		cur_frame;
	int		framebuf_count;
	int		framebuf_pos;
	char	outbuf[sizeof(rtp_hdr_t) + DIF_BLOCK_PER_PACKET * DIF_BLOCK_SIZE];
	rtp_hdr_t* pRtpHdr;
	int64_t file_len;
	int64_t bytes_read;
	int64_t start_time;
	int64_t frame_count;
	double frame_time;
	int64_t bytes_sent;
	double byte_rate;
	int64_t packet_start_time;
};

#endif // !defined FILE_DV_SOURCE_H

